import React, { Component } from 'react'
import './index.css'

export default class Demo7 extends Component {
  render() {
    return (
      <div>
        <A render={carName=><B carName={carName}/>}/>
      </div>
    )
  }
}

class A extends Component {

  state={carName:'领克03'}

  render() {
    const { carName } = this.state
    return (
      <div className='parent'>
        <h2>我是组件A</h2>
        <h3>我传的数据是：{carName}</h3>   
        {this.props.render(carName)} 
      </div>
    )
  }
}

class B extends Component {
  render() {
    const { carName } = this.props
    return (
      <div className='child'>
        <h2>我是组件B</h2>
        <h3>我接收的数据是：{carName}</h3>
      </div>
    )
  }
}

